package com.api.group.createfolder;

import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.api.test.VoidContextLoader;
import com.zyncro.api.IGroupApiService;
import com.zyncro.api.exceptions.ZyncroApiException;
import com.zyncro.api.model.ObjectResultApi;

@ContextConfiguration(loader = VoidContextLoader.class)
public class CreateManyFolders extends AbstractApiTest {

	private String userId;
	private String userPassword;

	private String idgroup;

	private static long folderNumber;

	@BeforeClass
	public void setUpVariables() {

		this.userId = "matiasdameno";
		this.userPassword = "eduardo";

		CreateManyFolders.folderNumber = 1;

		this.idgroup = "syncrum:sharegroup:e5ec43d6-c1a4-475f-b580-7d11d8f6d39e";

		getApi().login(userId, userPassword);
	}

	@Test(invocationCount = 59)
	public synchronized void testAddUser() throws ZyncroApiException {

		String name = "folder" + folderNumber;
		String description = null;

		try {
			ObjectResultApi<String> result = getApi().getService(IGroupApiService.class).createFolder(idgroup, name, description);
			logger.info(result.getObject());
		} catch (Exception e) {
			logger.warn(e);
		}
		folderNumber++;
	}
}
